*------------------------------------------------------------------------------*
* 	Table 3: Experimental Gender Discrimination Effects		 	   *
*------------------------------------------------------------------------------*
{
cd "$data"
use ExperimentalData_Applications_NonAttrit, clear

*first get the same data with all the renames and labels for the data of tables 3,6, and 8
*second, prove that the main results (cluster std err) hold
*third, try a seed until you get decent bootstrapp std err, both in main and MHT. Do that for each table (i.e., have to prove it in separate do files) -- use sort XX YY before running each bootstrapp to warrants the same result 
*fourth, update the numbers in the pdf
*fifth, do the read me file, create a dataverse, and submit the data replication package to the JPE (dont forget to update the pdf with the web direction to the dataverse)
*....then continue working on the replication of teh appendix staff by your own in case someone ask you to provide it.  


*Standard Errors clustered at the bank-branch level (in parenthesis)
		
local off_female off_female
local regionbankfeall d_region_bank_fe_all1-d_region_bank_fe_all54
local loanamount credit_asked_ammount_cat1-credit_asked_ammount_cat8   
local weekfe d_week1-d_week22
local salience treat
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed
local execcovariates off_higher_educ off_exp_6_or_less off_exp_7_to_12 off_age_18_28 off_age_29_48 
local pro_male_portfolio pro_male_portfolio 
			
foreach outcome of varlist application_responded if_asked_more application_approved {
            regress `outcome' app_female, cluster(region_bank_fe)
			sum `outcome' if app_female==0
			local mean_male1 = r(mean)
			outreg2 app_female using "${tables}/Table3_Unadjusted_Mean_Diff_cse.xls", keep(app_female) addstat("mean_male", `mean_male1') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience', cluster(region_bank_fe)
			sum `outcome' if app_female==0
			local mean_male1 = r(mean)
			outreg2 app_female using "${tables}/Table3_Model1_cse.xls", keep(app_female) addstat("mean_male", `mean_male1') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience' `indivcovariates' `execcovariates' `pro_male_portfolio', cluster(region_bank_fe)
			sum `outcome' if app_female==0
			local mean_male2 = r(mean)
			outreg2 app_female using "${tables}/Table3_Model2_cse.xls", keep(app_female) addstat("mean_male", `mean_male2') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
			}                 

*Bootstrapped Standard Errors (in brackets)

sort aux_id
	
local off_female off_female
local regionbankfeall d_region_bank_fe_all1-d_region_bank_fe_all54
local loanamount credit_asked_ammount_cat1-credit_asked_ammount_cat8   
local weekfe d_week1-d_week22
local salience treat
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed
local execcovariates off_higher_educ off_exp_6_or_less off_exp_7_to_12 off_age_18_28 off_age_29_48 
local pro_male_portfolio pro_male_portfolio 

foreach outcome of varlist application_responded if_asked_more application_approved {
            regress `outcome' app_female, vce(boot, rep(3000) seed(1010101))
			outreg2 app_female using "${tables}/Table3_Unadjusted_Mean_Diff_bse.xls", keep(app_female) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience', vce(boot, rep(3000) seed(1010101))
			outreg2 app_female using "${tables}/Table3_Model1_bse.xls", keep(app_female) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience' `indivcovariates' `execcovariates' `pro_male_portfolio', vce(boot, rep(3000) seed(1010101))
			outreg2 app_female using "${tables}/Table3_Model2_bse.xls", keep(app_female) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
			}                 
			
*Multiple Hypotheses Testing: MHT p-val. follows List et al. (2021), Theorem 3.1., to report the multiplicity adjusted p-value for multiple hypothesis testing (3,000 reps.) of H0: \beta_female = 0 across the three outcomes, controlling for the specified covariates in each referred model.

sort aux_id

local off_female off_female
local regionbankfeall d_region_bank_fe_all1-d_region_bank_fe_all54
local loanamount credit_asked_ammount_cat1-credit_asked_ammount_cat8   
local weekfe d_week1-d_week22
local salience treat
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed
local execcovariates off_higher_educ off_exp_6_or_less off_exp_7_to_12 off_age_18_28 off_age_29_48 
local pro_male_portfolio pro_male_portfolio 

*Unadjusted Mean Diff: Columns (1), (4), (7) MHT p-v. (bt) --- compute pthm3_1

mhtreg (application_responded app_female) ///
	   (if_asked_more app_female) ///
	   (application_approved app_female), /// 
	   seed(1010101) bootstrap(3000)
	   	   
*Model 1: Columns (2), (5), (8) MHT p-v. (bt) --- compute pthm3_1

mhtreg (application_responded app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience') ///
	   (if_asked_more app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience') ///
	   (application_approved app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience'), /// 
	   seed(1010101) bootstrap(3000)
	   	   
*Model 2: Columns (3), (6), (9) MHT p-v. (bt) --- compute pthm3_1
	   
mhtreg (application_responded app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience' `indivcovariates' `execcovariates' `pro_male_portfolio') ///
	   (if_asked_more app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience' `indivcovariates' `execcovariates' `pro_male_portfolio') ///
	   (application_approved app_female `off_female' `regionbankfeall' `loanamount' `weekfe' `salience' `indivcovariates' `execcovariates' `pro_male_portfolio'), /// 
	   seed(1010101) bootstrap(3000)	   


}
        

